[fix] Anthropic CUA triple_click mapping (#2104)#2107
Open
miguelg719 wants to merge 3 commits into
Open
Conversation
# Why
`AnthropicCUAClient.convertToolUseToAction()` handled actions like
`click`, `double_click`, and `left_click`, but did not explicitly
support `triple_click`.
Two issues:
1. The action type remained in snake_case (`triple_click`) instead of
being normalized to `tripleClick` — the format expected by
`v3CuaAgentHandler.executeAction()`.
2. Coordinates provided via Anthropic’s coordinate: [x, y] format were
not converted into the separate x / y fields required by the handler.
As a result, Anthropic triple-click actions were silently ignored by the
handler switch.
# What Changed
- AnthropicCUAClient.ts
- Added explicit handling for triple_click / tripleClick in
convertToolUseToAction()
- Mirrors the existing double_click implementation
- Normalizes action type to tripleClick
- Extracts coordinates from both:
- coordinate: [x, y]
- direct x / y fields
- v3CuaAgentHandler.ts
- Added "triple_click" as a switch-case alias in executeAction()
# Test Plan
Added `anthropic-cua-triple-click.test.ts` (Vitest) covering:
- triple_click with coordinate: [x, y]
- triple_click with direct x / y fields
All existing unit tests continue to pass.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fix incorrect handling of Anthropic CUA `triple_click` so triple-click
actions run and coordinates are parsed correctly. Adds unit tests for
both coordinate-array and x/y formats, and a changeset for a patch
release.
- **Bug Fixes**
- Normalize `triple_click`/`tripleClick` to internal `tripleClick` in
`AnthropicCUAClient`, extracting `x`/`y` from `coordinate` or explicit
fields.
- Add `"triple_click"` case to `V3CuaAgentHandler` so both naming styles
execute consistently.
- **Dependencies**
- Add changeset to publish a patch for `@browserbasehq/stagehand`.
<sup>Written for commit 7a54548.
Summary will update on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: a230bfc The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant CUA as Anthropic CUA API
participant Client as AnthropicCUAClient
participant Handler as V3CuaAgentHandler
participant Browser as Browser Action Executor
Note over CUA,Browser: Triple Click Action Mapping Flow
CUA->>Client: tool_use: action="triple_click", input={coordinate=[x,y]}
Client->>Client: convertToolUseToAction()
Note over Client: Check action type
alt action == "triple_click" || action == "tripleClick"
Client->>Client: Extract coordinates from coordinate[] or direct x/y
Client->>Client: Build action: {type:"tripleClick", x, y}
end
Client-->>Handler: executeAction({type:"tripleClick", x, y})
Handler->>Handler: executeAction(action)
alt action.type == "tripleClick" || action.type == "triple_click"
Handler->>Handler: Parse x, y from action
Handler->>Browser: Click(x, y, count=3)
Browser-->>Handler: {success: true}
Handler-->>Client: {success: true}
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
AnthropicCUAClient.convertToolUseToAction()handled actions likeclick,double_click, andleft_click, but did not explicitly supporttriple_click.Two issues:
triple_click) instead of being normalized totripleClick— the format expected byv3CuaAgentHandler.executeAction().As a result, Anthropic triple-click actions were silently ignored by the handler switch.
What Changed
AnthropicCUAClient.ts
Added explicit handling for triple_click / tripleClick in convertToolUseToAction()
v3CuaAgentHandler.ts
Test Plan
Added
anthropic-cua-triple-click.test.ts(Vitest) covering:All existing unit tests continue to pass.
Summary by cubic
Fixes Anthropic CUA
triple_clickso it runs astripleClickwith x/y parsed fromcoordinate: [x, y]or explicit fields. Also adds a CI job to run evals unit tests.Bug Fixes
triple_click/tripleClicktotripleClickinAnthropicCUAClient.convertToolUseToAction().x/yfromcoordinate: [x, y]or direct fields."triple_click"alias inv3CuaAgentHandler.executeAction().Dependencies
@browserbasehq/stagehand.Written for commit a230bfc. Summary will update on new commits.